home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Applications / FlyThrough 1.1.2 / src / Source / QD3D General Tools / StQ3Disposer.h < prev    next >
Encoding:
Text File  |  1997-03-01  |  541 b   |  24 lines  |  [TEXT/CWIE]

  1. //
  2. //    StQ3Disposer.h
  3. //
  4. //    by James Jennings
  5. //
  6. // A clever little utility for automatically disposing of QD3D objects.
  7. // Note that we can either attach the TQ3Object in the constructor,
  8. // or with operator=().
  9.  
  10. #pragma once
  11. #include <QD3D.h>
  12.  
  13. class StQ3Disposer {
  14. public:
  15.     StQ3Disposer(TQ3Object obj = 0) : theObject(obj) 
  16.         {}
  17.     ~StQ3Disposer(void) 
  18.         { if (theObject) ::Q3Object_Dispose(theObject); }
  19.     StQ3Disposer & operator=(TQ3Object obj)
  20.         { Assert_(theObject==nil); theObject = obj; return *this; }
  21. private:
  22.     TQ3Object theObject;
  23. };
  24.